<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/6/15 0015
 * Time: 11:57
 */

namespace app\common\model;


use think\Model;

class MemInfo extends Model
{
    /*
     * 通过手机号查询用户
     * */
    public function SelectData($whereArr,$field = "*"){
        if (empty($whereArr)){
            return $this->query('select '.$field.' from xb_mem_info');
        }else{
            $str = '';
            foreach ($whereArr as $k=>$v){
                $str.= $k.'=:'.$k.' and';
            }
            $str = rtrim($str,'and');
            $data = $this->query('select '.$field.' from xb_mem_info where '.$str.'limit 1',$whereArr);
            return !empty($data)?$data[0]:[];
        }
//        return $this->query('select * from xb_mem_info where mobile=:mobile',['mobile'=>$Mobile]);
    }
    /*
     * 添加用户
     * */
    public function addUser($data = []){
        if (empty($data)) return false;
        $data['RegTime'] = date('Y-m-d H:i:s',time());
        $data['LimitBalcance'] = model('Goods')->showDefont();
        return $this->insert($data);
    }
}